package com.ecommerce.payment.client;

import com.ecommerce.payment.dto.ThirdPartyPaymentResult;
import com.ecommerce.payment.entity.Payment;
import com.ecommerce.payment.dto.CreatePaymentRequest;
import org.springframework.stereotype.Component;

/**
 * 微信支付客户端
 */
@Component
public class WechatPayClient {

    /**
     * 创建支付
     *
     * @param payment 支付实体
     * @param request 创建支付请求
     * @return 第三方支付结果
     */
    public ThirdPartyPaymentResult createPayment(Payment payment, CreatePaymentRequest request) {
        ThirdPartyPaymentResult result = new ThirdPartyPaymentResult();
        // 模拟微信支付逻辑
        result.setSuccess(true);
        result.setThirdPartyPaymentNo("WX" + System.currentTimeMillis());
        result.setAmount(request.getAmount().toString());
        // 模拟二维码
        result.setExtraParams("weixin://wxpay/bizpayurl?pr=ETaG4Gz");
        return result;
    }
}